<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>序列化</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                // ?username=admin&password=123456&phone=13812345678&address=江苏-南京
                // let username = $("input[name='username']").val();
                // let password = $("input[name='password']").val();
                // console.log("?username="+username+"&password="+password)
                // 序列化方法只会处理带有name属性的元素
                console.log($("#userForm").serialize())
            });
        })
    </script>
</head>
<body>
<form action="#" id="userForm">
    用户名:<input type="text" name="username"><br>
    密码:<input type="password" name="password"><br>
    电话:<input type="text" name="phone"><br>
    地址:<input type="text" name="address"><br>
    <!--    <input type="submit" value="提交">-->
    <input type="button" id="btn" value="提交">
</form>
</body>
</html>